home *** CD-ROM | disk | FTP | other *** search
/ Amiga Collections: Topik / Topik - Disk 37 - Games 3 (19xx)(Topik Public Domain)(PD)[WB].zip / Topik - Disk 37 - Games 3 (19xx)(Topik Public Domain)(PD)[WB].adf / RUMMY / SOURCE / playgame.c.pp / playgame.c
C/C++ Source or Header  |  1991-02-24  |  14KB  |  518 lines

  1. /* PLAYGAME.C
  2.  * This file has the functions to play a game, including the functions to
  3.  * play a game, manipulate the pack.
  4.  */
  5.  
  6. #include    <proto/all.h>
  7. #include    <stdlib.h>
  8. #include    <math.h>
  9. #include    <intuition/intuition.h>
  10. #include    <string.h>
  11. #include    "defns.h"
  12. #include    "externs.h"
  13.  
  14. VOID    playgame(USHORT nplr)
  15. {
  16.     ULONG    pln=0,nc=0,win=0;
  17.     USHORT    nextplr,startplr=1,i,j,hand=0,nhp;
  18.     stdgad[5].Flags &= ~SELECTED; stdgad[6].Flags &= ~SELECTED;
  19.     AddGList(wind,&stdgad[3],-1,5,NULL);
  20.     RefreshGList(&stdgad[3],wind,NULL,5);
  21.     initplrs();
  22.     exgm=0;
  23.     if(!mandeal)
  24.     { /*pack will be reinitialised in manualdeal()*/
  25.         if(initpack[BEFOREGAME]) initialisepack();
  26.         if(shufpack[BEFOREGAME]) shuffle();
  27.     }
  28.     while(!quit && !exgm && ++hand<=numhand)
  29.     {
  30.         for(pln=1,nhp=0;pln<=nplr;pln++)
  31.         {
  32.             if(plr[pln]->manctrl) nhp++;
  33.             plr[pln]->turn=0;
  34.             stci_d(out,plr[pln]->score);
  35.             TXTOUT(270,plr[pln]->yc+SCTPY,1,0,out)
  36.             stci_d(out,plr[pln]->wins);
  37.             TXTOUT(270,plr[pln]->yc+NWTPY,1,0,out)
  38.             for(i=1;i<=52;i++) plr[pln]->mem[i]=UNKNOWN;
  39.         }
  40.         win=0;
  41.         nextplr=startplr;
  42.         if(!mandeal)
  43.         {/*pack will be reinitialised in manualdeal()*/
  44.             if(initpack[BEFOREHAND]) initialisepack();
  45.             if(shufpack[BEFOREHAND]) shuffle();
  46.         }
  47.         if(!mandeal || !manualdeal(nplr)) /*autodeal*/
  48.         {
  49.             for(nc=1;nc<=7;nc++)
  50.                 for(pln=1;pln<=nplr;pln++)
  51.                 {
  52.                     plr[pln]->hand[nc]=NEXTFDP;
  53.                     plr[pln]->mem[CARD2(plr[pln]->hand[nc])] = CURRPLRHOLDS;
  54.                 }
  55.             plr[1]->nchld=plr[2]->nchld=plr[3]->nchld=7;
  56.             for(pln=1;pln<=nplr;pln++) hsort(plr[pln]->hand,plr[pln]->nchld);
  57.         }
  58.         PUTFUP(NEXTFDP);
  59.         DrawImage(wind->RPort,packim[0][CARD2(fup[fuptc])],FUPX,FUPY);
  60.         DrawImage(wind->RPort,packim[0][0],FDPX,FDPY);
  61.         for(pln=1;pln<=nplr;pln++) if(plr[pln]->viewcard) disphand(plr[pln]);
  62.                                     else hidecards(plr[pln]);
  63.         while(!quit && !exgm && !win)
  64.         {
  65.             plr[nextplr]->turn++;
  66.             SETPTR(ptrs[nextplr])
  67.             if((plr[nextplr]->level+10)<rand()%21) corrupt(plr[nextplr]); /*corrupt player memory*/
  68.             if(plr[nextplr]->manctrl)
  69.                 manturn(plr[nextplr],plr[nextplr==nplr?1:nextplr+1],
  70.                 nplr==2?NULL:plr[nextplr==1?nplr:nextplr-1],nhp);
  71.             else 
  72.             {
  73.                 OffMenu(wind,0x0020); /*reorder off*/
  74.                 OffMenu(wind,0xf862); /*modmem off*/
  75.                 OffMenu(wind,0x0040); /*about off*/
  76.                 autoturn(plr[nextplr],plr[nextplr==nplr?1:nextplr+1],
  77.                 nplr==2?NULL:plr[nextplr==1?nplr:nextplr-1]);
  78.                 OnMenu(wind,0x0020); /*reorder on*/
  79.                 OnMenu(wind,0xf862); /*modmem on*/
  80.                 OnMenu(wind,0x0040); /*about on*/
  81.             }
  82.             win = plr[nextplr]->nchld ?0 :nextplr;
  83.             nextplr = nextplr==nplr ?1 :nextplr+1;    /*another player's turn*/
  84.         }
  85.         SETPTR(ptrs[0])
  86.         if(win) for(i=1;i<=nplr;i++) disphand(plr[i]);
  87.         /*return cards to pack and update losers scores*/
  88.         while(fuptc>0) PUTFDP(NEXTFUP);    /*return face up pack to main pack*/
  89.             for(pln=1;pln<=nplr;pln++)
  90.                 while(plr[pln]->nchld) plr[pln]->score+=(PUTFDP(NEXTPLC(plr[pln]))).n;
  91.         for(i=0;i<=5 && fupset[i]->ncard!=0;i++)
  92.         { /*return cards from face up sets*/
  93.             for(j=1;j<=14;j++)
  94.                 if(!CDEQU(fupset[i]->cards[j],nulcard))
  95.                 {
  96.                     PUTFDP(fupset[i]->cards[j]);
  97.                     fupset[i]->cards[j]=nulcard;
  98.                 }
  99.             fupset[i]->ncard=0;
  100.         }
  101.         if(win)
  102.         {/*continuous mode will not display round winners*/
  103.             plr[win]->wins++;
  104.             if(!contplay) displaywin(plr[win],nplr,hand,numhand);
  105.         }
  106.         DrawImage(wind->RPort,packim[0][0],FUPX,FUPY);
  107.         startplr = startplr==nplr ?1 :startplr+1;    /*next plr goes first in next game*/
  108.         DrawImage(wind->RPort,&setrem,0,0); /*remove submitted sets*/
  109.         sortdispset();    /*remove set gadgets*/
  110.         for(pln=1;pln<=nplr;pln++)
  111.         {
  112.             DrawImage(wind->RPort,&handrem,0,plr[pln]->yc+HANDTOP);
  113.             TXTOUT(270,plr[pln]->yc+HVTPY,1,0,"      ");
  114.             TXTOUT(270,plr[pln]->yc+NWTPY,1,0,"      ");
  115.             TXTOUT(270,plr[pln]->yc+SCTPY,1,0,"      ");
  116.             TXTOUT(270,plr[pln]->yc+NWTPY+9,1,0,"      ");
  117.         }
  118.     }    
  119.     displayresult(nplr); /*overall result still displayed in continuous mode*/
  120.     RemoveGList(wind,&stdgad[3],5);
  121.     RefreshGList(&stdgad[3],wind,NULL,5);
  122. }
  123.  
  124. VOID    initplrs()
  125. {    /*Initialise for start of game*/
  126.     register    USHORT    p,c;
  127.     for(p=1;p!=4;p++)
  128.     {
  129.         plr[p]->score = 0;
  130.         for(c=1;c!=53;c++) plr[p]->mem[c]=UNKNOWN;
  131.         for(c=0;c!=8;c++) plr[p]->hand[c]=nulcard;
  132.         plr[p]->nchld = 0;
  133.         plr[p]->wins = 0;
  134.     }
  135.     for(p=0;p!=6;p++)
  136.     {
  137.         fupset[p]->ncard=0;
  138.         for(c=1;c!=15;c++) fupset[p]->cards[c]=nulcard;
  139.     }
  140. }
  141.  
  142.  
  143. VOID    initialisepack()
  144. {
  145.     register    USHORT    s,n,t;
  146.     for(s=DM;s<=SP;s++)
  147.         for(n=ACE;n<=KING;n++)
  148.         {
  149.             fdp[t=s*13+n].s=s;
  150.             fdp[t].n=n;
  151.         }
  152.     fdptc=52;fuptc=0;
  153. }    
  154.  
  155. VOID    shuffle()
  156. {
  157.     register    USHORT    mid,nb,top,nt,nc,cnt; /*, nextbottom,,nexttop,destination pos*/
  158.     register    long    dec;
  159.     USHORT    pass=0;
  160.     struct    card    tpack[53];    /*temporary pack*/
  161.     mid = fdptc >> 1;    /*middle of face down pack*/
  162.     top    = fdptc;
  163.     cont = 0;
  164.     TXTOUT(MESX,MESY,1,0,"Select Continue....")
  165.     while(!cont && !quit && !exgm && ++pass<100)
  166.     {
  167.         nb=mid; nt=top; nc=0;
  168.         while(nb && nt>mid)
  169.         {
  170.             dec = rand(); /*random number*/
  171.             for(cnt=32;cnt && nb && nt>mid;cnt--)
  172.                 if(!((dec>>=1)&1)) tpack[++nc]=fdp[nb--]; /*card from lower half of pack*/
  173.                 else tpack[++nc]=fdp[nt--]; /*card from upper half of pack*/
  174.         }
  175.         
  176.         if(!nb) while(nt>mid) tpack[++nc]=fdp[nt--]; /*copy rest of top half*/
  177.         else while(nb) tpack[++nc]=fdp[nb--]; /*copy rest of bottom half*/
  178.         /*shuffle back to fdp[]*/
  179.         nb=mid; nt=top; nc=0;
  180.         while(nb && nt>mid)
  181.         {
  182.             dec = rand();
  183.             for(cnt=32;cnt && nb && nt>mid;cnt--)
  184.                 if((dec>>=1)&1) fdp[++nc]=tpack[nt--]; /*from top half*/
  185.                 else fdp[++nc]=tpack[nb--]; /*bottom half*/
  186.         }
  187.         if(!nb) while(nt>mid) fdp[++nc]=tpack[nt--]; /*copy top*/
  188.         else while(nb) fdp[++nc]=tpack[nb--];
  189.     }
  190. }
  191.  
  192. USHORT    manualdeal(USHORT nplr)
  193. {
  194.     struct    IntuiMessage    *msg;
  195.     struct    Gadget    *gaddr;
  196.     register    USHORT    pln=1,i,pos;
  197.     register    ULONG    class,gid;
  198.     USHORT    fin=0,cardno=0,rval=0;
  199.     initcardgads();
  200.     initialisepack();
  201.     SETPTR(ptrs[1])
  202.     Request(&mdreq,wind);
  203.     while(!fin)
  204.     {
  205.         Wait(1<<mp->mp_SigBit);
  206.         while(msg=(struct IntuiMessage *)GetMsg(mp))
  207.         {
  208.             class=msg->Class;
  209.             gaddr=(struct Gadget *)msg->IAddress;
  210.             ReplyMsg((struct Message *)msg);
  211.             if(class==GADGETUP)
  212.             {
  213.                 gid=gaddr->GadgetID;
  214.                 if(gid>CARDG && gid<=CARDG+52)
  215.                 {
  216.                     if(cardgads[cardno=gid-CARDG].Flags&SELECTED)
  217.                     {
  218.                         if(plr[pln]->nchld<7)
  219.                         { /*add card to hand*/
  220.                             plr[pln]->hand[++(plr[pln]->nchld)]=fdp[cardno];
  221.                             disphand(plr[pln]);
  222.                         }
  223.                         else
  224.                         { /*deselect card*/
  225.                             pos=RemoveGadget(wind,&cardgads[cardno]);
  226.                             cardgads[cardno].Flags &= ~SELECTED;
  227.                             AddGList(wind,&cardgads[cardno],pos,1,&mdreq);
  228.                             if(cardno<=13) RefreshGList(&cardgads[1],wind,&mdreq,13);
  229.                             else if(cardno<=26) RefreshGList(&cardgads[14],wind,&mdreq,13);
  230.                             else if(cardno<=39) RefreshGList(&cardgads[27],wind,&mdreq,13);
  231.                             else RefreshGList(&cardgads[40],wind,&mdreq,13);
  232.                         }
  233.                     }
  234.                     else if(!(cardgads[cardno].Flags&SELECTED) && plr[pln]->nchld)
  235.                     { /* remove card from hand*/
  236.                         for(i=1;i<=plr[pln]->nchld && !CDEQU(plr[pln]->hand[i],fdp[cardno]);i++);
  237.                         if(CDEQU(plr[pln]->hand[i],fdp[cardno]))
  238.                         {
  239.                             plr[pln]->hand[i]=nulcard;
  240.                             compacthand(plr[pln]->hand,&plr[pln]->nchld);
  241.                             REMHAND(plr[pln]);
  242.                             disphand(plr[pln]);
  243.                         }
  244.                     }
  245.                 }
  246.                 else if(gid==MDACCEPTG)
  247.                 { /*disable gadgets and remove selected cards from pack*/
  248.                     pos=RemoveGList(wind,&cardgads[1],52);
  249.                     for(i=1;i<=plr[pln]->nchld;i++)
  250.                     {
  251.                         cardno=CARD2(plr[pln]->hand[i]);
  252.                         cardgads[cardno].Flags |= GADGDISABLED;
  253.                         fdp[cardno]=nulcard;
  254.                         plr[pln]->mem[cardno]=CURRPLRHOLDS;
  255.                     }
  256.                     AddGList(wind,&cardgads[1],pos,52,&mdreq);
  257.                     RefreshGList(&cardgads[1],wind,&mdreq,52);
  258.                     if(pln!=nplr)
  259.                     { /*set new ptr in here*/
  260.                         pln++;
  261.                         SETPTR(ptrs[pln])
  262.                     }
  263.                     else
  264.                     {
  265.                         fin=rval=1;
  266.                         EndRequest(&mdreq,wind);
  267.                         compacthand(fdp,&fdptc);
  268.                         if(shufpack[BEFOREGAME] || shufpack[BEFOREHAND]) shuffle();
  269.                     }
  270.                 }
  271.                 else if(gid==MDAUTODG)
  272.                 {
  273.                     initialisepack();
  274.                     if(shufpack[BEFOREGAME] || shufpack[BEFOREHAND]) shuffle();
  275.                     plr[1]->nchld=plr[2]->nchld=plr[3]->nchld=0;
  276.                     fin=1;
  277.                     rval=0;
  278.                 }
  279.             }
  280.         }
  281.     }
  282.     SETPTR(ptrs[0])
  283.     /*restore original pointer*/
  284.     return rval;
  285. }
  286.  
  287. struct    card    rvspk()
  288. {    /*only use NEXTFDP from within another macro when it is known that 
  289.     rvspk() cannot be called*/
  290.      
  291.     struct    card    tc,c;
  292.     USHORT    n;
  293.     tc=fdp[1];    /*top card*/
  294.     fdptc=0;
  295.     while(fuptc)
  296.     {
  297.         c=PUTFDP(NEXTFUP);
  298.         plr[1]->mem[n=CARD2(c)] &= ~GONEPAST;
  299.         plr[2]->mem[n] &= ~GONEPAST;
  300.         plr[3]->mem[n] &= ~GONEPAST;
  301.     }
  302.     shuffle();
  303.     return tc;
  304. }
  305.  
  306.  
  307. VOID    displaywin(p,nplr,r,nr)
  308. struct    playerinfo    *p;
  309. USHORT    nplr,r,nr;
  310. {
  311.     struct    IntuiMessage    *msg;
  312.     register    USHORT    fin=0;
  313.     stci_d(intbuf[0],plr[1]->score);
  314.     stci_d(intbuf[1],plr[2]->score);
  315.     stci_d(intbuf[2],plr[3]->score);
  316.     stci_d(intbuf[3],r);
  317.     stci_d(intbuf[4],nr);
  318.     rwtxt[4].IText = p->name;
  319.     Request(&rwreq,wind);
  320.     while(!fin)
  321.     {
  322.         Wait(1<<mp->mp_SigBit);
  323.         while(msg=(struct IntuiMessage *)GetMsg(mp))
  324.         {
  325.             if(msg->Class == GADGETUP && ((struct Gadget *)(msg->IAddress))->GadgetID==PROCG) fin=1;
  326.             ReplyMsg((struct Message *)msg);
  327.         }
  328.     }
  329. }
  330.  
  331. VOID    displayresult(USHORT nplr)
  332. {
  333.     struct    IntuiMessage    *msg;
  334.     register    USHORT    fin=0;
  335.     struct    playerinfo    *p;
  336.     if(plr[1]->score>plr[2]->score) p=plr[2]; else p=plr[1];
  337.     if(nplr==3 && p->score>plr[3]->score) p=plr[3];
  338.     switch(p->playernum)
  339.     {
  340.     case 1:    if(p->score==plr[2]->score || nplr==3 && p->score==plr[3]->score) gwreq.ReqText = &gwtxt[2]; /*draw*/
  341.             else gwreq.ReqText = &gwtxt[0];
  342.             break;
  343.     case 2:    if(p->score==plr[1]->score || nplr==3 && p->score==plr[3]->score) gwreq.ReqText = &gwtxt[2]; /*draw*/
  344.             else gwreq.ReqText = &gwtxt[0];
  345.             break;
  346.     case 3:    if(p->score==plr[1]->score || p->score==plr[2]->score) gwreq.ReqText = &gwtxt[2]; /*draw*/
  347.             else gwreq.ReqText = &gwtxt[0];
  348.             break;
  349.     }
  350.     stci_d(intbuf[0],plr[1]->score);
  351.     stci_d(intbuf[1],plr[2]->score);
  352.     stci_d(intbuf[2],plr[3]->score);
  353.     stci_d(intbuf[5],plr[1]->wins);
  354.     stci_d(intbuf[6],plr[2]->wins);
  355.     stci_d(intbuf[7],plr[3]->wins);
  356.     gwtxt[1].IText = p->name;
  357.     Request(&gwreq,wind);
  358.     while(!fin)
  359.     {
  360.         Wait(1<<mp->mp_SigBit);
  361.         while(msg=(struct IntuiMessage *)GetMsg(mp))
  362.         {
  363.             if(msg->Class == GADGETUP && ((struct Gadget *)(msg->IAddress))->GadgetID==PROCG) fin=1;
  364.             ReplyMsg((struct Message *)msg);
  365.         }
  366.     }
  367. }
  368.  
  369. VOID    reorder(struct playerinfo *p)
  370. {
  371.     struct    IntuiMessage    *msg;
  372.     struct    Gadget    *gaddr;
  373.     register     USHORT    n,pos,gpos;
  374.     register    ULONG    class,gid;
  375.     struct    card    t[8];
  376.     OffMenu(wind,0x0020); /*reorder off*/
  377.     OffMenu(wind,0xf862); /*modmem off*/
  378.     OffMenu(wind,0x0040); /*about off*/
  379.     gpos=RemoveGList(wind,&stdgad[3],5);
  380.     handgads(p->nchld,p->yc); /*reset gadgets*/
  381.     TXTOUT(MESX,MESY,1,0,"Select For Left to Right Display")
  382.     for(n=p->nchld;n && !quit && !exgm;)
  383.     {
  384.         Wait(1 << mp->mp_SigBit);
  385.         while(msg=(struct IntuiMessage *)GetMsg(mp))
  386.         {
  387.             class=msg->Class;
  388.             gaddr=(struct Gadget *)(msg->IAddress);
  389.             ReplyMsg((struct Message *)msg);
  390.             if(class==GADGETUP && (gid=gaddr->GadgetID)>=HANDG1 && gid<=HANDG7)
  391.             {
  392.                 t[n--]=p->hand[gid-HANDG1+1];
  393.                 pos=RemoveGadget(wind,gaddr);
  394.                 gaddr->Flags |= GADGDISABLED;
  395.                 AddGadget(wind,gaddr,pos);
  396.             }
  397.         }
  398.     }
  399.     if(!quit && !exgm)
  400.     {
  401.         for(n=1;n<=p->nchld;n++) p->hand[n]=t[n];
  402.         handgads(p->nchld,p->yc); /*reset gadgets*/
  403.         disphand(p);
  404.         TXTOUT(MESX,MESY,1,0,"Reorder Complete                 ")
  405.     }
  406.     AddGList(wind,&stdgad[3],gpos,5,NULL);
  407.     OnMenu(wind,0x0020); /*reorder on*/
  408.     OnMenu(wind,0xf862); /*modmem on*/
  409.     OnMenu(wind,0x0040); /*about on*/
  410. }
  411.             
  412.  
  413.  
  414. VOID    modmem(struct playerinfo *p)
  415. {
  416.     struct    IntuiMessage    *msg;
  417.     struct    Gadget    *gaddr;
  418.     register    USHORT    i,fin=0;
  419.     USHORT    m[53],pos,cardno=0,t;
  420.     ULONG    class,gid;
  421.     initcardgads();
  422.     mmtxt[13].IText = p->name;
  423.     for(i=0;i<=7;i++) mmgads[i].Flags &= ~SELECTED;
  424.     for(i=1;i!=53;i++) m[i]=p->mem[i];
  425.     Request(&mmreq,wind);
  426.     while(!fin)
  427.     {
  428.         Wait(1<<mp->mp_SigBit);
  429.         while(msg=(struct IntuiMessage *)GetMsg(mp))
  430.         {
  431.             gaddr=(struct Gadget *)msg->IAddress;
  432.             class=msg->Class;
  433.             ReplyMsg((struct Message *)msg);
  434.             if(class==GADGETUP)
  435.             {
  436.                 gid=gaddr->GadgetID;
  437.                 if(gid>CARDG && gid<=CARDG+52)
  438.                 {
  439.                     if(cardno && cardno!=(gid-CARDG))
  440.                     {/* deselect previous card*/
  441.                         cardgads[cardno].Flags &= ~SELECTED;
  442.                         if(cardno<=13) RefreshGList(&cardgads[1],wind,&mmreq,cardno+1);
  443.                         else if(cardno<=26) RefreshGList(&cardgads[14],wind,&mmreq,cardno-12);
  444.                         else if(cardno<=39) RefreshGList(&cardgads[27],wind,&mmreq,cardno-25);
  445.                         else RefreshGList(&cardgads[40],wind,&mmreq,cardno-38);
  446.                     }
  447.                     pos=RemoveGList(wind,&mmgads[0],8);
  448.                     RefreshGList(&mmgads[0],wind,&mmreq,8);
  449.                     t=m[cardno=gid-CARDG];
  450.                     if(cardgads[cardno].Flags&SELECTED)
  451.                     {
  452.                         for(i=0;i<=7;i++)
  453.                             if((t>>i)&1) mmgads[i].Flags |= SELECTED;
  454.                             else mmgads[i].Flags &= ~SELECTED;
  455.                     }
  456.                     else
  457.                     {
  458.                         for(i=0;i<=7;i++) mmgads[i].Flags &= ~SELECTED;
  459.                         cardno=0;    /*no card active*/
  460.                     }
  461.                     AddGList(wind,&mmgads[0],pos,8,&mmreq);
  462.                     RefreshGList(&mmgads[0],wind,&mmreq,8);
  463.                 }
  464.                 else if(gid==MMSETFG)
  465.                 {
  466.                     for(i=0;i<=7;i++)
  467.                         if(mmgads[i].Flags&SELECTED) m[cardno]|=(1<<i);
  468.                         else m[cardno]&=~(1<<i);
  469.                 }
  470.                 else if(gid==MMACCEPTG)
  471.                 {
  472.                     for(i=1;i<=52;i++) p->mem[i]=m[i];
  473.                     fin=1;
  474.                 }
  475.                 else if(gid==MMCANCELG) fin=1;
  476.             }
  477.         }
  478.     }
  479. }
  480.  
  481. VOID    corrupt(struct playerinfo *p)
  482. { /*corrupt memory of player p*/
  483.     long    l;
  484.     l=rand();
  485.     if(l&256) p->mem[l%52] = l&255;
  486.     if(l&512) p->mem[(l>>1)%52] |= l&(l>>10);
  487.     if(l&1024) p->mem[(l>>5)%52] &= l&(l>>20);
  488. }
  489.  
  490. VOID    initcardgads()
  491. { /*initialise card gadgets for manual deal and modify memory.*/
  492.     register    USHORT    s,n,d;
  493.     for(s=3;s!=-1;s--)
  494.         for(n=13;n;n--)
  495.         {
  496.             d=s*13+n;    /*card number*/
  497.             cardgads[d]=cardgads[0];    /*initialise*/
  498.             cardgads[d].NextGadget = &cardgads[d+1];
  499.             if(n==13)
  500.             {
  501.                 cardgads[d].LeftEdge=210;
  502.                 cardgads[d].Width=64;
  503.                 cardgads[d].SpecialInfo = (APTR)&wide;
  504.             }
  505.             else
  506.             {
  507.                 cardgads[d].LeftEdge=cardgads[d+1].LeftEdge - 17;
  508.                 cardgads[d].Width=17;
  509.                 cardgads[d].SpecialInfo = (APTR)&narrow;
  510.             }
  511.             cardgads[d].TopEdge=50*s+20;
  512.             cardgads[d].GadgetRender=(APTR)packim[(n==13)?0:1][d];
  513.             cardgads[d].GadgetID=d+CARDG;
  514.             cardgads[d].Flags &= ~(SELECTED | GADGDISABLED);
  515.         }
  516.     cardgads[52].NextGadget=NULL;
  517. }
  518.